package com.banmao.mall.controller.client;

import com.banmao.mall.model.bo.client.comment.CommentListBO;
import com.banmao.mall.model.pojo.Comment;
import com.banmao.mall.model.vo.BaseRespVO;
import com.banmao.mall.model.vo.client.comment.CommentCountVO;
import com.banmao.mall.model.vo.client.comment.CommentListWxVO;
import com.banmao.mall.service.client.CommentServiceWx;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController("commentControllerWx")
@RequestMapping("wx/comment")
public class CommentController {

    @Autowired
    CommentServiceWx commentServiceWx;

    @RequestMapping("list")
    public BaseRespVO list(CommentListBO commentListBO) {
        CommentListWxVO commentListWxVO = commentServiceWx.select(commentListBO);
        return BaseRespVO.ok(commentListWxVO);
    }

    @RequestMapping("count")
    public BaseRespVO count(Integer valueId, Byte type) {
        CommentCountVO commentCountVO = commentServiceWx.count(valueId,type);
        return BaseRespVO.ok(commentCountVO);
    }

    @RequestMapping("post")
    public BaseRespVO post(@RequestBody Comment commentBO) throws IllegalAccessException {
        Comment commentVO = commentServiceWx.post(commentBO);
        return BaseRespVO.ok(commentVO);
    }

}
